import 'package:flutter/material.dart';

class Btn extends StatelessWidget {
  final String tag;
  final String title;
  final Color color;
  final void Function() onTap;
  final void Function() onTagTap;

  const Btn(
      {super.key,
      required this.onTap,
      required this.onTagTap,
      required this.title,
      this.tag = '',
      this.color = Colors.red});

  @override
  Widget build(BuildContext context) {
    return Card(
        child: InkWell(
      splashColor: const Color.fromARGB(255,13,110,253),
      // onTap: () async {
      //   debugPrint('Card tapped.');
      //   try {
      //     int num = int.parse(tag);
      //     int result = await Door.open(num);
      //     debugPrint('$result');
      //   } catch (e) {
      //     debugPrint(e.toString());
      //   }
      // },
      onTap: onTap,
      child: SizedBox(
        width: 80,
        height: 80,
        child: Stack(children: [
          tag == ''
              ? const SizedBox()
              : Row(
                  children: [
                    IconButton(
                        onPressed: onTagTap,
                        icon: Icon(
                          Icons.local_offer,
                          color: title == '' ? Colors.grey : color,
                        )),
                    Text(
                      tag,
                      style: TextStyle(
                          color: title == '' ? Colors.grey : color,
                          fontWeight: FontWeight.bold,
                          fontSize: 20),
                    )
                  ],
                ),
          Container(
            alignment: (title.length==4||title.length==5)?Alignment.bottomCenter:Alignment.center,
            child: Text(title,
                style: TextStyle(
                    color:  (title.length==5)?const Color.fromARGB(255,165, 42, 42):const Color.fromARGB(255,13,110,253),
                    fontWeight: FontWeight.bold,
                    fontSize: 26)),
          )
        ]),
      ),
    ));
  }
}
